<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>


<div class="table-responsive">
    <div class="row">
        <div class="col-xs-3">
            <form class="form-inline">
                <div class="form-group">
                    <label>公司名称</label>
                    <input type="text" class="form-control">
                </div>
            </form>
        </div>

        <div class="col-xs-3">
            <form class="form-inline">
                <div class="form-group">
                    <label>客户名称</label>
                    <input type="text" class="form-control" id="exampleInputName2" >
                </div>
            </form>
        </div>
        <div class="col-xs-3" >
            <button type="button" class="btn btn-warning col-xs-3" style="float: left;margin-left:20px" onclick="init()">查询</button>
        </div>
        <div class="col-xs-12" style="height: 20px"></div>
        <div class="col-xs-12">
            <div class="doc-buttons">
                &nbsp;
                <c:forEach items="${btn}" var="key">
                    ${key}
                </c:forEach>
            </div>
        </div>
    </div>
    <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/inventory/highcharts.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/inventory/exporting.js"></script>

<script type="text/javascript">

   var json;
   var arr = new Array();
    $(document).ready(function(){

        init();
    });
    function init(){
        $.ajax({url: rootPath + '/sc/getMaterialCount.shtml',
            type:"get",
            dataType:"json",
            async:false,
            success:function(data){
                json= eval('(' + data + ')');
                console.log(json);
                $.each(json,function(index,s){
                    arr[index]=s;
                });

            }
        });
        charts();
    }
    function charts(){
        $('#container').highcharts({
            chart: {
                type: 'column'
            },
            colors: [
                '#B5CA92',
                '#AA4643',
                '#92A8CD',
                '#A47D7C',
                '#DB843D',
                '#3D96AE',
                '#80699B',
                '#89A54E',
                '#4572A7'
            ],
            title: {
                text: '盘点汇总'
            },
            subtitle: {
                text: arr[0].WSingleTime.substr(0,4)+"年",
                style:{color:'#AA4643',
                    fontSize:'13px'}
            },
            xAxis: {
                categories: [
                    '一月',
                    '二月',
                    '三月',
                    '四月',
                    '五月',
                    '六月',
                    '七月',
                    '八月',
                    '九月',
                    '十月',
                    '十一月',
                    '十二月'
                ]
            },
            yAxis: {
                min: 0,
                title: {
                    text: '单位:kg'
                }
            },
            tooltip: {
                headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
                pointFormat: '<tr><td style="color:{series.color};padding:0">测试 </td>' +
                    '<td style="padding:0"><b>{point.y:.1f} '+'</b></td></tr>',
                footerFormat: '</table>',
                shared: true,
                useHTML: true
            },
            plotOptions: {
                column: {
                    pointPadding: 0.2,
                    borderWidth: 0
                }
            },
            credits:{
                href: "",
                text: ''
            },
            series: [{
                name: '预盘数量',
                data: [arr[0].quantityNo,arr[1].quantityNo,arr[2].quantityNo,arr[3].quantityNo,arr[4].quantityNo,
                    arr[5].quantityNo,arr[6].quantityNo,arr[7].quantityNo,arr[8].quantityNo,arr[9].quantityNo,
                    arr[10].quantityNo,arr[11].quantityNo]

            }, {
                name: '实盘数量',
                data: [arr[0].actualNo,arr[1].actualNo,arr[2].actualNo,arr[3].actualNo,arr[4].actualNo,
                    arr[5].actualNo,arr[6].actualNo,arr[7].actualNo,arr[8].actualNo,arr[9].actualNo,
                    arr[10].actualNo,arr[11].actualNo]

            }]
        });


    }

    function submit1() {
        var id = document.getElementById('item').value;
        var time = document.getElementById('time').value;
        if (isNaN(time)) {
            alert("您输入的年份不正确");
            return;
        }

        $.ajax({
            url: "stockTaking!getSummaryJson?year=" + time + "&id=" + id + "&randomtiem=" + (new Date().getTime()),
            type: "get",
            dataType: "json",
            async: false,
            success: function (data) {
                json = eval('(' + data + ')');
                $.each(json, function (index, s) {
                    arr[index] = s;
                });
            }
        });
        if (arr[0].flag == 0) {
            alert("此产品在该年份没有盘点记录");
            return;
        }
        charts();
    }


</script>